<!DOCTYPE HTML>
<html>
<head>
<include file="Include:meta" />
<title>营销计划管理-目的地运营集团数据管理平台</title>
<include file="Include:style" />
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text">运营管理 > 营销计划管理</div>
		<div class="right">
			<div class="input-group left w250">
		    	<input type="text" id="keyword" value="{$keyword}" class="form-control" placeholder="按项目编号/名称搜索" autocomplete="off">
	    		<span class="input-group-btn">
	        		<button class="btn found_btn" type="button">搜索</button>
		    	</span>
		    </div>
		</div>
	</div>
	<div id="content">
		<div class="relative mb10">
			<table class="table table-bordered table-hover">
				<tr class="table-header fixed-table-header">
					<td>项目编号</td>
					<td>计划分类</td>
					<td>时间阶段</td>
					<td>附件</td>
					<td width="140">申请人(日期)</td>
					<td>当前状态</td>
					<td width="100">
						<select name="state" class="form-control w100">
							<option value="-10" <if condition="$state eq -10">selected</if>>状态</option>
							<option value="1" <if condition="$state eq 1">selected</if>>进行中</option>
							<option value="2" <if condition="$state eq 2">selected</if>>已完结</option>
						</select>
					</td>
				</tr>
				<if condition="$result eq NULL">
				<tr><td class='text-center' colspan="7">暂无相关内容</td></tr>
				</if>
				<foreach name="result" item="vo">
					<tr class="interlaced-color">
						<td><span title="{$vo['project_name']}" data-placement="right" data-toggle="tooltip">{$vo['project_num']}</span></td>
						<td>{$vo['type_name']}</td>
						<td>{$vo['time_stage']}</td>
						<td>
						<foreach name="vo['file_url']" item="vv" key="vkey">
						{$vo['file_name'][$vkey]}<a href="{$vv}" did="{$vo['id']}" target="_blank" data-toggle="tooltip" data-placement="right" title="下载" class="ml5 mr15"><i class="glyphicon glyphicon-download-alt"></i></a>
						</foreach>
						</td>
						<td>{$vo['add_user']}({$vo['add_date']|substr=0,10})</td>
						<td style="padding:0" class="ding">
							<div class="project_user_alert">
								<if condition="$vo['status'] eq -1">未提交<if condition="$vo['back_user'] neq NULL"><span title="{$vo['back_user']}({$vo['back_date']|substr=0,10}):{$vo['back_to_resaon']}" data-placement="left" data-toggle="tooltip" class="red">(已打回)<span></if>
								<elseif condition="$vo['status'] eq 4"/>已完结<i class="glyphicon glyphicon-exclamation-sign ml10" style="color:#999"></i>
								<else />
									<if condition="$vo['status'] eq 1">待【{$vo['audit_user']}】审核<i class="glyphicon glyphicon-exclamation-sign ml10" style="color:#999"></i>
									<elseif condition="$vo['status'] eq 2"/>待【{$vo['audit_user']}】审核<i class="glyphicon glyphicon-exclamation-sign ml10" style="color:#999"></i>
									<elseif condition="$vo['status'] eq 3"/>待【{$vo['audit_user']}】审核<i class="glyphicon glyphicon-exclamation-sign ml10" style="color:#999"></i>
									</if>
								</if>
								<if condition="$vo['status'] gt -1">
								<div class="project_user_box">
									<if condition="$vo['status'] neq -1">
										<div class="project_user_title">审核流程</div>
										<foreach name="vo['audit_arr']" item="vv">
											<div class="p"><span class="bold">{$vv['audit_name']}</span>
											<if condition="$vv['audit_date'] neq NULL">
												<span>{$vv['audit_user']}({$vv['audit_date']|substr=0,10})<if condition="$vv['audit_comments'] neq NULL">:{$vv['audit_comments']}</if></span>
												<if condition="$vv['dh_message'] neq NULL"><br/><span>打回至"{$vv['arrive_name']}"({$vv['dh_date']|substr=0,10})原因:{$vv['dh_message']}</span></if><if condition="$vv['arrive_info'] neq NULL"><br/><span>"{$vv['arrive_name']}"({$vv['arrive_date']|substr=0,10})回复:{$vv['arrive_info']}</span></if>
											<else/>
												<span class='red'>[未审核]{$vv['audit_user']}</span>
												<if condition="$vv['dh_message'] neq NULL"><br/><span class='red'>打回至"{$vv['arrive_name']}"({$vv['dh_date']|substr=0,10}原因:{$vv['dh_message']})</span></if><if condition="$vv['arrive_info'] neq NULL"><br/><span class='red'>"{$vv['arrive_name']}"({$vv['arrive_date']|substr=0,10})回复：{$vv['arrive_info']}</span></if>
											</if>
											</div>
										</foreach>
									</if>
									<!--<if condition="$vo['back_user'] neq NULL">
										<div class="p"><span class="red bold">打回原因 </span><span class="red">{$vo['back_user']}({$vo['back_date']|substr=0,10}):{$vo['back_to_resaon']}</span></div>
									</if>
									<if condition="$vo['submit_info'] neq NULL">
										<div class="p"><span class="red bold">重新提交 </span><span class="red">{$vo['submit_user']}:{$vo['submit_info']}</span></div>
									</if>-->
								</div>
								</if>
							</div>
						</td>
						<td>
							<if condition="(1 eq $vo['status']) and (1 eq $pa)">
								<a href="javascript:;" status="audit1" mid="{$vo['id']}" class="travel_to_up1 marginRight10">审核</a>
								<a href="javascript:;" status="audit3" mid="{$vo['id']}" class="travel_to_up1 marginRight10">完结</a>
								<a href="javascript:;" status="back_audit" mid="{$vo['id']}" dh_status="{$vo['status']}" class="travel_to_back marginRight10">打回</a>
							<elseif condition="(2 eq $vo['status']) and (2 eq $pa)"/>
								<a href="javascript:;" status="audit2" mid="{$vo['id']}" class="travel_to_up1 marginRight10">审核</a>
								<a href="javascript:;" status="audit3" mid="{$vo['id']}" class="travel_to_up1 marginRight10">完结</a>
								<a href="javascript:;" status="back_audit" mid="{$vo['id']}" dh_status="{$vo['status']}" class="travel_to_back marginRight10">打回</a>
							<elseif condition="(3 eq $vo['status']) and (3 eq $pa)"/>
								<a href="javascript:;" status="audit3" mid="{$vo['id']}" class="travel_to_up1 marginRight10">完结</a>
								<a href="javascript:;" status="back_audit" mid="{$vo['id']}" dh_status="{$vo['status']}" class="travel_to_back marginRight10">打回</a>
							</if>
							<if condition="(1 eq $pa) and (($vo['status'] eq 2) or ($vo['audit2_uid'] eq NULL and $vo['status'] eq 4))">
								<a href="javascript:;" status="audit1_give" mid="{$vo['id']}" class="travel_to_up marginRight10">弃审</a>
							<elseif condition="(2 eq $pa) and (($vo['status'] eq 3) or ($vo['audit3_uid'] eq NULL and $vo['status'] eq 4))"/>
								<a href="javascript:;" status="audit2_give" mid="{$vo['id']}" class="travel_to_up marginRight10">弃审</a>
							<elseif condition="(3 eq $pa) and ($vo['status'] eq 4)"/>
								<a href="javascript:;" status="audit3_give" mid="{$vo['id']}" class="travel_to_up marginRight10">弃审</a>
							</if>
						</td>
					</tr>
				</foreach>
			</table>
		</div>
		<div class="pages">{$page}</div>
	</div>
</div>
<div class="modal fade" id="myModal_dahui">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h4>打回</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">
				<table class="table table-bordered">
					<tr>
						<td class="text-right" width="95"><strong><span class="asterisk">*</span>打回阶段</strong></td>
						<td>
							<select name="arrive_status" class="form-control required-selted" autocomplete="off">
								<!--<option value="-10" selected>请选择</option>
								<foreach name="audit_list" item="vo">
									<option value="{$vo['audit_sort']}">{$vo['audit_name']}</option>
								</foreach>-->
							</select>
							<span class="error-item">必填项</span>
						</td>
					</tr>
					<tr>
						<td class="text-right" width="95"><strong><span class="asterisk">*</span>是否重走流程</strong></td>
						<td class="radios">
							<label class="radio-inline"><input type="radio" name="flow_status" value="1" autocomplete="off">是</label>
							<label class="radio-inline"><input type="radio" name="flow_status" value="-1" autocomplete="off">否</label>
							<span class="error-item">必填项</span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>原因</strong></td>
						<td>
							<textarea name="remark" class="form-control w300 reason left" autocomplete="off"></textarea>
							<span class="error-item left">必填项</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-affirm">确认</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<!--弹框-->
<div class="modal fade" id="edit-modal">
	<div class="modal-dialog w600">
		<div class="modal-content">
			<div class="modal-header">
				<h4></h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body" style="line-height:30px;">
				<table class="table table-bordered">
					<tr>
						<td class="text-right" width="74"><strong><span class="asterisk">*</span>审核</strong></td>
						<td>
							<textarea name="text_hid" class="form-control required-text" style="width:100%; height:150px" autocomplete="off"></textarea>
							<input type="hidden" name="audit_message">
							<span class="error-item">必填项</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-affirm">确认</button><button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript">
$(function(){
	$('span.relative').hover(function(){
		$(this).find('.tooltip_cont').toggleClass('active');
	})
	//搜索
	$(".found_btn").keywordSearch("__APP__/Index/project_plan_list/keyword/$keyword/pa/{$pa}/state/{$state}");

	//状态筛选
	$(document).on("change","[name='state']",function(){
		var val = $(this).val();
		window.location.href="__APP__/Index/project_plan_list/keyword/{$keyword}/pa/{$pa}/state/"+val;
	});
	
	
	$("[name='text_hid']").each(function(){
		var textss = $(this).text(),
			reg2 = new RegExp("<br/>", "g"),
			str = textss.replace(reg2, "\n");
		$(this).html(str);
	})
	//文本域暂存
	$("[name='text_hid']").blur(function(){
		var val = $(this).val();
			reg = new RegExp("\n", "g"),
    		str = val.replace(reg, "<br/>");
		$("[name='audit_message']").val(str);
	})
	//审核弹框
	$(".travel_to_up1").on("click",function(){
		var modal = $("#edit-modal"),
			mid = $(this).attr("mid"),
			status = $(this).attr("status");
		modal.find(".modal-header h4").text("审核");
		modal.find(".file-name").prop("readonly",true);
		modal.find(".file-delete").hide();
		modal.find(".btn-affirm").attr({"mid":mid});
		modal.find(".btn-affirm").attr({"status":status});
		modal.modal();
		modal.find("textarea").val('');
	});
	//取消
	$("#edit-modal").on('hidden.bs.modal',function(){
		$(this).find(".error-item").hide();
	});
	//审核
	$("#edit-modal").find(".btn-affirm").on("click",function(){
		var tag = false;
		$(".required-text").each(function(){
			var val = $(this).val();
			if(val=="" || /^\s+$/.test(val)){
				$(this).next(".error-item").show();
				tag = true;
			}
		});
		
		if(tag){
			return false;
		}else{
			var status = $(this).attr('status'),
				mid = $(this).attr('mid'),
				audit_message = $("[name='audit_message']").val(),
				modal = $("#edit-modal");
			modal.hide();
			$.ajax({
				type:"POST",
				dataType:"json",
				async: false,
				url:"__APP__/Project/project_plan_audit",
				data:{"mid":mid,"status":status,"audit_message":audit_message},
				success:function(data){
					success_pop(data['status'],data['msg']);
				}
			});
		}
	});
	$(document).on("focus",".required-text",function(){
		$(this).nextAll(".error-item").hide();
	});
	//弃审
	$('.travel_to_up').click(function(){
		var status = $(this).attr('status');
		var mid = $(this).attr('mid');
		$.ajax({
			type:"POST",
			dataType:"json",
			async: false,
			url:"__APP__/Project/project_plan_audit",
			data:{"mid":mid,"status":status},
			success:function(data){
				success_pop(data['status'],data['msg']);
			}
		});
	});
	//打回
	$('.travel_to_back').click(function(){
		var mid = $(this).attr('mid'),
			dh_status = $(this).attr('dh_status');
		$("#myModal_dahui").find(".btn-affirm").attr("mid",mid);
		$("#myModal_dahui").find(".btn-affirm").attr("dh_status",dh_status);
		$("#myModal_dahui").modal();
		$("#myModal_dahui").find("textarea").val('');
		$("#myModal_dahui").find("[name='arrive_status']").val('-10').select2();
		$("#myModal_dahui").find("[name='flow_status']").attr('checked',false);
		$.ajax({
			type:"POST",
			dataType:"json",
			async: false,
			url:"__APP__/Project/project_plan_ajax",
			data:{"id":mid,"action":'dh_list'},
			success:function(data){
				var html="";
				html+= "<option value='-10' selected>请选择</option>";
				for(var i=0; i<data.length; i++){
					html+= "<option value='"+data[i].audit_sort+"'>"+data[i].audit_name+"</option>";
				}
				$("[name='arrive_status']").html(html).select2();
			}
		});
	});
	
	$("#myModal_dahui .btn-affirm").on("click",function(){
		var tag = false;
		$(".reason").each(function(){
			var val = $(this).val();
			if(val=="" || /^\s+$/.test(val)){
				$(this).next(".error-item").show();
				tag = true;
			}
		});
		$("[name='arrive_status']").each(function(){
			var val = $(this).val();
			if(val==-10){
				$(this).nextAll(".error-item").show();
				tag = true;
			}
		})
		if($("#myModal_dahui").find("input:radio:checked").length==0){
			$("#myModal_dahui .radios").find(".error-item").show();
			tag = true;
		}
		if(tag){
			return false;
		}else{
			var modal = $("#myModal_dahui"),
				mid = $("#myModal_dahui").find(".btn-affirm").attr("mid"),
				dh_status = $("#myModal_dahui").find(".btn-affirm").attr("dh_status"),
				arrive_status = $("[name='arrive_status']").val(),
				flow_status = modal.find('input:radio:checked').val(),
				reason = $(".reason").val();
				modal.hide();
				$.ajax({
					type:"POST",
					dataType:"json",
					async: false,
					url:"__APP__/Project/project_plan_audit",
					data:{"mid":mid,"status":"back_audit","reason":reason,"flow_status":flow_status,"arrive_status":arrive_status,"dh_status":dh_status},
					success:function(data){
						success_pop(data['status'],data['msg']);
					}
				});
				$(".close").click();
		}
	})
	$(document).on("focus",".reason",function(){
		$(this).nextAll(".error-item").hide();
	});
	$("[name='arrive_status']").change(function(){
		$(this).nextAll(".error-item").hide();
	})
	$("#myModal_dahui .radios label").click(function(){
		$("#myModal_dahui .radios .error-item").hide();
	})
});
</script>
</body>
</html>